import { Component, Input, OnInit } from '@angular/core';
import { PageModalService } from 'src/app/shared/service/page-modal-service';
import { AppGlobalService } from 'src/app/shared/service/app-global.service';
@Component({
  selector: 'app-service-list',
  templateUrl: './service-list.component.html',
  styleUrls: ['./service-list.component.scss'],
})
export class ServiceListComponent implements OnInit {
  @Input() tagData: any;
  constructor(
    private pageModalService: PageModalService,
    private appGlobalService: AppGlobalService,
  ) { }

  ngOnInit() {
    if (this.tagData.data[0] && this.tagData.data[0].isShow !== undefined) {
      this.appGlobalService.floatShoppingCartObj = this.tagData.data[0];
      this.appGlobalService.showfloatShoppingCart(true);
    }
  }
  go(item) {
    this.pageModalService.openPage(item.link);
  }
  ngOnDestroy(): void {
    this.appGlobalService.showfloatShoppingCart(false);
    // tslint:disable-next-line: no-string-literal
    if (this.appGlobalService.floatShoppingCartObj["isShow"] === true) {
      delete this.appGlobalService.floatShoppingCartObj["isShow"];
    }
    console.log("退出floatShoppingCart");
  }
}
